<?php


namespace App\Http\Controllers\Manage\System;


use App\Http\Controllers\Controller;
use App\Http\Requests\Manage\System\ExpressBlacklist\StoreRequest;
use App\Repositories\ExpressBlacklist;

class ExpressBlacklistController extends Controller
{
    /**
     * @var ExpressBlacklist
     * @author luffyzhao@vip.126.com
     */
    private $blacklist;

    /**
     * ExpressBlacklistController constructor.
     * @param ExpressBlacklist $blacklist
     * @author luffyzhao@vip.126.com
     */
    public function __construct(ExpressBlacklist $blacklist)
    {
        $this->blacklist = $blacklist;
    }

    /**
     * @param $id
     * @return \Illuminate\Http\JsonResponse
     * @author luffyzhao@vip.126.com
     */
    public function index($id)
    {
        return $this->response(
            $this->blacklist->lists($id)
        );
    }

    /**
     * @param StoreRequest $request
     * @param $id
     * @return \Illuminate\Http\JsonResponse
     * @author luffyzhao@vip.126.com
     */
    public function store(StoreRequest $request, $id)
    {
        return $this->response(
            $this->blacklist->create(
                $request->only(['address']) + ['express_id' => $id]
            )
        );
    }

    /**
     * @param $expressId
     * @param $id
     * @return \Illuminate\Http\JsonResponse
     * @author luffyzhao@vip.126.com
     */
    public function destroy($expressId, $id)
    {
        return $this->response(
            $this->blacklist->destroy($expressId, $id)
        );
    }
}